package org.jeecg.modules.system.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.config.swagger.BusinessApi;
import org.jeecg.modules.system.dto.UserPermissionFilterDTO;
import org.jeecg.modules.system.entity.SysUserPermissionFilter;
import org.jeecg.modules.system.service.ISysUserPermissionFilterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "用户权限过滤")
@RestController
@BusinessApi
@RequestMapping("/sys/sysUserPermissionFilter")
@Slf4j
public class SysUserPermissionFilterController extends JeecgController<SysUserPermissionFilter, ISysUserPermissionFilterService> {
    @Autowired
    private ISysUserPermissionFilterService sysUserPermissionFilterService;

    @AutoLog(value = "用户权限过滤表-编辑")
    @ApiOperation(value = "用户权限过滤表-编辑", notes = "用户权限过滤表-编辑")
//    @RequiresPermissions("sys:sys_user_permission_filter:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT})
    public Result<String> edit(@RequestBody UserPermissionFilterDTO userPermissionFilterDTO) {
        sysUserPermissionFilterService.setUserFilterPerms(userPermissionFilterDTO.getUserId(), userPermissionFilterDTO.getExcludedPermissionIds());
        return Result.OK("编辑成功!");
    }

}
